package com.leesche.zcsp.node.web.constants;

import java.math.BigDecimal;
import java.text.DecimalFormat;

/**
 * @author dennies yang
 * @version V1.0
 * @Title: Constants.java
 * @Package com.leesche.zcsp.node.constants
 * @Description:(静态类)
 * @date 2016年9月21日 下午5:05:14
 */
public class Constants {

    public static final String SUCCESS = "SUCCESS";
    public static final String FAIL = "FAIL";

    // 登录验证码
    public static final String LOGIN_CODE = "LOGIN_CODE";
    // 当前登录用户
    public static final String LOGIN_CURRENT_USER = "LOGIN_CURRENT_USER";
    // 手机短信验证码
    public static final String MOBILE_SMS_CODE = "MOBILE_SMS_CODE";
    // 已接收短信的手机号码
    public static final String MOBILE_NUMBER = "MOBILE_NUMBER";
    // 没有用支付宝或微信息扫扫
    public static final String PAY_SCAN_NO_WAY = "PAY_SCAN_NO_WAY";
    // 用支付宝扫扫
    public static final String PAY_SCAN_ALIPAY = "PAY_SCAN_ALIPAY";
    // 用微信扫扫
    public static final String PAY_SCAN_WEIXIN = "PAY_SCAN_WEIXIN";
    // 校验结果KEY
    public static final String VERIFY_RESULT = "VERIFY_RESULT";

    public static final String SPILTTMARK = "-";


    public final static int STATE_AUTHOR = 0; // 授权
    public final static int STATE_ORDER = 1; // 下单
    public final static int STATE_SUCEESS = 2; // 购买成功

    public final static int WECHAT_SUCCESS = 1; //SUCCESS—支付成功 1
    public final static int WECHAT_REFUND = 2; //REFUND—转入退款  2
    public final static int WECHAT_NOTPAY = 3; //NOTPAY—未支付 3
    public final static int WECHAT_CLOSED = 4; //CLOSED—已关闭 4
    public final static int WECHAT_REVOKED = 5; //REVOKED—已撤销（刷卡支付）5


    /** ------------------------------------- 订单表支付状态trade_state ------------------------------------ */
    public static final int TRADE_STATE_SUCCESS = 1;//支付成功
    public static final int TRADE_STATE_REFUND = 2;//转入退款
    public static final int TRADE_STATE_NOTPAY = 3;//未支付
    public static final int TRADE_STATE_CLOSED = 4;//已关闭
    public static final int TRADE_STATE_REVOKED = 5;//已撤销
    public static final int TRADE_STATE_USERPAYING = 6;//用户支付中
    public static final int TRADE_STATE_PAYERROR = 7;//支付失败(其他原因，如银行返回失败)



    //当前站点名称
    public final static String SITE_NAME = "node";

    public final static String APP_NAME = "youyicloud";

    //权限的类型
    //web权限
    public final static Integer MODULE_TYPE_WEB = 1;
    //微信权限
    public final static Integer MODULE_TYPE_WECHAT = 2;
    //APP权限
    public final static Integer MODULE_TYPE_APP = 3;
    //操作权限
    public final static Integer MODULE_TYPE_OPERATION = 4;

    //微信
    public final static Integer CASH_LOSTTYPE_WECHAT = 1;
    //取现失败
    public final static Integer CASH_LOSTSTATUS_FAILTURE = 0;
    //取现成功
    public final static Integer CASH_LOSTSTATUS_SUCCESS = 1;

    public final static String NOTICE_DEFAULT_LOGOURL = "resources/images/wechat/login_tx.png";//web/banner.png
    public final static String NOTIC_DEFAULT_COMPANYNAME = "游艺设备智能物联";//广州力禧捷电子科技有限公司
    public final static String NOTIC_DEFAULT_BUTTOMCONTENT = "游艺设备智能物联";//广州力禧捷电子科技有限公司

    public final static String NOTIC_DEFAULT_ERRORVIEW_NOWECHATACCESS = "/error/nowechatopen.jsp";
    public final static String NOTIC_DEFAULT_ERRORVIEW_NOMODULE = "/error/nomodule.jsp";

    //系统用户的默认密码（123456）经JSMD5加密
    public final static String NOTIC_DEFAULT_USER_PASSWORD = "nnb0OmhyjRNhrTFIe4J+mQ";
    //系统手机验证码默认最大有效期（单位：分钟）
    public final static Integer NOTIC_DEFAULT_MOBLIE_CODE_MAXINACTIVEINTERVAL = 10;
    //系统默认分页最大显示条数（单位：分钟）
    public final static Integer NOTIC_DEFAULT_PAGEING_ROWS_MAXNUMBER = 10;
    //系统用户身份证照片存储位置
    public final static String SYSTEM_TMAGE_IDCARD_DIRECTORY = "/data/useridCardDirectory";
    //系统移动端APP的存储下载位置
    public final static String SYSTEM_TMAGE_APK_DIRECTORY = "upload/ApplicationDirectory";
    //系统用户LOGO图片的存在位置
    public final static String SYSTEM_TMAGE_USERLOGO_DIRECTORY = "upload/UserLogoDirectory";
    //用户吐槽图片的存在位置
    public final static String SYSTEM_TMAGE_COMPLAIN_DIRECTORY = "upload/ComplainDirectory";
    //设备图片的存在位置
    public final static String SYSTEM_TMAGE_DEVICE_DIRECTORY = "upload/DeviceDirectory";
    //设备礼品图片的存在位置
    public final static String SYSTEM_TMAGE_DEVICE_GIFT_DIRECTORY = "upload/DeviceGiftDirectory";
    //设备参数图片的存在位置
    public final static String SYSTEM_TMAGE_DEVICE_PARAM_DIRECTORY = "upload/DeviceParam";
    //系统默认图片大小 （  1MB ）
    public final static Integer SYSTEM_IMAGE_SIZE = (1024 * 1000);
    //系统默认图片魔术字（用于验证图片合法性）｛gif,jpg/jpeg,png,TIFF (tif)｝
    public final static String[] SYSTEM_IMAGE_MAGICNUMBER = new String[]{"47494638", "ffd8ffe0","ffd8ffe1", "89504e47","49492A00"};
    //系统默认APP魔术字（用于验证图片合法性）｛ZIP包、RAR包、7z包｝
    public final static String[] SYSTEM_APP_MAGICNUMBER = new String[]{"504b0304", "52617221","377abcaf"};
    //未上传LOGO时，文件框默认图片
    public final static String SYSTEM_DEFAULT_UPLOADIMAGE = "resources/images/wechat/ico_mrlogo.png";
    //未上传LOGO时，WEB端文件框默认图片
    public final static String SYSTEM_WEB_DEFAULT_UPLOADIMAGE = "resources/images/web/v2/my/logoshangbiao.png";


    // 系统金额格式
    public static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("####,####,###0.00");
    // 网络支付金额转换百分比
    public static final BigDecimal percentage = new BigDecimal(100);

    // 系统异常，提示信息
    public static final String SYSTEM_ERROR_PROMPT_MSG = "系统繁忙,请稍后重试";

    //系统短信通知内容
    public static String getMobileCodeVaildMsg(String moblieCode) {
        return "验证码已发送，请注意查收";
    }

    public enum CashType {
        One(1, 4), Five(5, 5), Ten(10, 6), Twenty(20, 7), Fify(50, 8), Hunderd(100, 9);
        private Integer cashType;
        private Integer cashIndex;

        private CashType(Integer cashType, Integer cashIndex) {
            this.cashType = cashType;
            this.cashIndex = cashIndex;
        }

        public static Integer getCachType(int index) {
            for (CashType dt : CashType.values()) {
                if (dt.cashIndex == index) {
                    return dt.cashType;
                }
            }
            return null;
        }
    }

    //web端当日明细
    public enum DetailType {
        Coin("<span>一元硬币</span><i>number</i>个<em>￥total</em>", 1),
        WechatPay("<p>微信支付</p><em>￥total</em>", 2),
        Alipay("<p>支付宝支付</p><em>￥total</em>", 3),
        Beill("<span>cach</span>元<i>number</i>张<em>￥total</em>", 4),
        DeviceAddCoin("<p>出币</p><em>total个</em>", 10),
        RemotelyOutCoin("<p>远程补币</p><em>total个</em>", 11),
        gameCoin("<p>投入游戏币</p><em>total个</em>", 12),
        gift("<p>出礼品</p><em>total个</em>", 13),
        manualOutCoin("<p>优惠劵购币</p><em>total个</em>", 14);

        private String typeText;
        private int typeIndex;

        private DetailType(String typeText, int typeIndex) {
            this.typeText = typeText;
            this.typeIndex = typeIndex;
        }

        public static String getText(int index) {
            if (index > 3 && index < 10) {
                index = 4;
            }
            for (DetailType dt : DetailType.values()) {
                if (dt.typeIndex == index) {
                    return dt.typeText;
                }
            }
            return null;
        }
    }

    //APP端当日明细标题
    public enum AppDetailTitle {
        Coin("一元硬币", 1),
        WechatPay("微信支付", 2),
        Alipay("支付宝支付", 3),
        Beill("纸钞支付", 4),
        DeviceAddCoin("出币", 10),
        RemotelyOutCoin("远程补币", 11),
        gameCoin("投入游戏币", 12),
        gift("出礼品", 13),
        manualOutCoin("优惠券购币", 14);

        private String title;
        private int titleIndex;

        private AppDetailTitle(String title, int titleIndex) {
            this.title = title;
            this.titleIndex = titleIndex;
        }

        public static String getText(int index) {
             if (index > 3 && index < 10) {
                index = 4;
            }
            for (AppDetailTitle dt : AppDetailTitle.values()) {
                if (dt.titleIndex == index) {
                    return dt.title;
                }
            }
            return null;
        }
    }

    //APP端当日明细内容
    public enum AppDetailContent {
        Money("￥number", 1),
        NotMoney("number个", 2),
        Cash("cach元number张-￥total", 3);

        private String content;
        private int contentIndex;

        private AppDetailContent(String content, int contentIndex) {
            this.content = content;
            this.contentIndex = contentIndex;
        }

        public static String getText(int index) {

            if (index <= 3 && index > 0) {
                index = 1;
            }else if(index >= 10){
                index = 2;
            } else if (index > 3 && index < 10) {
                index = 3;
            }

            for (AppDetailContent dt : AppDetailContent.values()) {
                if (dt.contentIndex == index) {
                    return dt.content;
                }
            }
            return null;
        }
    }

}
